package com.fstrat.webservices.restws;

import java.util.List;

import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;

import com.fstrat.backend.entities.Angebot;
import com.fstrat.services.AngebotService;

@Path("angebot")
public class AngebotWS {
	
	private AngebotService service;
	
	public AngebotWS(){
		service = new AngebotService();
	}
	
	@POST
	@Produces(MediaType.APPLICATION_JSON)
	@Path("alle")
	public List<Angebot> holeAlleAngebotePost() {
		return service.holeAlleEntities();
	}
	
	@GET
	@Produces(MediaType.APPLICATION_JSON)
	@Path("alle")
	public List<Angebot> holeAlleAngeboteGet() {
		return service.holeAlleEntities();
	}
	
	@POST
	@Consumes(MediaType.APPLICATION_JSON)
	@Produces(MediaType.APPLICATION_JSON)
	public Boolean schreibeAngebot(Angebot angebot){
		return (service.schreibeEntity(angebot) != null);
	}	
	
	@GET
	@Produces(MediaType.APPLICATION_JSON)
	public Angebot holeAngebotById(@QueryParam("id") Long id){
		return service.holeEntityById(id);
	}
}
